package com.sdgs.paas.sdk.core.metrics;

import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;

import com.sdgs.paas.sdk.core.log.PaasLogger;

/**
 * SDK 指标收集功能自动配置
 *
 * @author wjj
 */
@Configuration
@ConditionalOnClass({ PaasMethodMetricsAspect.class })
public class PaasMetricsAutoConfiguration {


//	@Override
//	public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
//	
//		StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter();
//		stringHttpMessageConverter.setWriteAcceptCharset(false);  // see SPR-7316
//
//		List<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>(4);
//		messageConverters.add(new ByteArrayHttpMessageConverter());
//		messageConverters.add(stringHttpMessageConverter);
//		messageConverters.add(new SourceHttpMessageConverter<Source>());
//		messageConverters.add(new AllEncompassingFormHttpMessageConverter());
//		messageConverters.add(new MappingJackson2HttpMessageConverter());
//		
//		argumentResolvers.add(new PaasMethodProcessor(messageConverters));
//	}

	@Bean
	public PaasMethodMetricsAspect createPaasMethodMetricsAspect(
			RequestMappingHandlerAdapter requestMappingHandlerAdapter) {

		PaasMethodMetricsAspect paasMethodMetricsAspect = new PaasMethodMetricsAspect();

		PaasLogger.info("PaasMethodMetricsAspect创建成功!");

		return paasMethodMetricsAspect;
	}

}
